﻿using System;
using System.Globalization;
using Dpx.Models;
using Dpx.Util;
using Xamarin.Forms;

namespace Dpx.Converters {
    /// <summary>
    /// 布局到文本对齐转换器。
    /// </summary>
    public class LayoutToTextAlignmentConverter : IValueConverter {
        public object Convert(object value, Type targetType, object parameter,
            CultureInfo culture) {
            return (value as string) switch {
                Poetry.CenterLayout => TextAlignment.Center,
                Poetry.IndentLayout => TextAlignment.Start,
                _ => null
            };
        }

        public object ConvertBack(object value, Type targetType,
            object parameter, CultureInfo culture) {
            throw new DoNotCallThisException();
        }
    }
}